<template>
  <div class="md-banner-base">
    <el-carousel>
      <el-carousel-item v-for="item in bannerData" :key="item.rid">
        <img v-if="bannerData[0]" :src="item.imageUrl" :alt="`banner${item.rid}`" :title="`banner${item.rid}`" />
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script>
export default {
  name: 'MdBannerBaseComponent',
  props: {
    src: {
      type: String,
      default: null
    }
  },
  data () {
    return {
      bannerData: []
    }
  },
  mounted () {
    this.getBannerData()
  },
  methods: {
    async getBannerData () {
      try {
        const res = await this.$axios.get('business/web/carousel/getCarouselList')

        this.bannerData = res.data
      } catch (error) {
        console.log(error)
      }
    },
    onSwiper () { },
    onSlideChange () { }
  }
}
</script>

<style lang="scss" scoped>
.md-banner-base {
  width: 100%;
  height: 586px;
  box-sizing: border-box;
  overflow: hidden;

  ::v-deep .el-carousel {
    height: 100%;
    .el-carousel__container {
      height: 100%;
      .el-carousel__item {
        img {
          display: block;
          width: 100%;
          height: 100%;
          object-fit: cover;
        }
      }
    }
  }
}
</style>